home *** CD-ROM | disk | FTP | other *** search
/ Multimedia Dogs / Multimedia Dogs v2.0.iso / mac / Extras / Tests / Tests.DXR / 00002_Button handlers.ls < prev    next >
Encoding:
Text File  |  1995-06-10  |  2.9 KB  |  75 lines

  1. global gpButtonShiftPixels
  2.  
  3. on initCustomButtons
  4.   set gpButtonShiftPixels to 1
  5. end
  6.  
  7. on customButtonBehavior theSprite
  8.   set the locH of sprite theSprite to the locH of sprite theSprite + gpButtonShiftPixels
  9.   set the locV of sprite theSprite to the locV of sprite theSprite + gpButtonShiftPixels
  10.   set buttonIsPressed to 1
  11.   updateStage()
  12.   repeat while the stillDown
  13.     if rollOver(theSprite) = 1 then
  14.       if buttonIsPressed = 0 then
  15.         set the locH of sprite theSprite to the locH of sprite theSprite + gpButtonShiftPixels
  16.         set the locV of sprite theSprite to the locV of sprite theSprite + gpButtonShiftPixels
  17.         set buttonIsPressed to 1
  18.       end if
  19.     else
  20.       if buttonIsPressed = 1 then
  21.         set the locH of sprite theSprite to the locH of sprite theSprite - gpButtonShiftPixels
  22.         set the locV of sprite theSprite to the locV of sprite theSprite - gpButtonShiftPixels
  23.         set buttonIsPressed to 0
  24.       end if
  25.     end if
  26.     updateStage()
  27.   end repeat
  28.   if buttonIsPressed = 1 then
  29.     set the locH of sprite theSprite to the locH of sprite theSprite - gpButtonShiftPixels
  30.     set the locV of sprite theSprite to the locV of sprite theSprite - gpButtonShiftPixels
  31.     updateStage()
  32.   end if
  33. end
  34.  
  35. on customButtonBehaviorMultiple theSpriteList
  36.   repeat with i = 1 to count(theSpriteList)
  37.     set theSprite to getAt(theSpriteList, i)
  38.     set the locH of sprite theSprite to the locH of sprite theSprite + gpButtonShiftPixels
  39.     set the locV of sprite theSprite to the locV of sprite theSprite + gpButtonShiftPixels
  40.     set gpButtonIsPressed to 1
  41.   end repeat
  42.   updateStage()
  43.   set theMasterSprite to getAt(theSpriteList, 1)
  44.   repeat while the stillDown
  45.     if rollOver(theMasterSprite) = 1 then
  46.       if gpButtonIsPressed = 0 then
  47.         repeat with i = 1 to count(theSpriteList)
  48.           set theSprite to getAt(theSpriteList, i)
  49.           set the locH of sprite theSprite to the locH of sprite theSprite + gpButtonShiftPixels
  50.           set the locV of sprite theSprite to the locV of sprite theSprite + gpButtonShiftPixels
  51.           set gpButtonIsPressed to 1
  52.         end repeat
  53.       end if
  54.     else
  55.       if gpButtonIsPressed = 1 then
  56.         repeat with i = 1 to count(theSpriteList)
  57.           set theSprite to getAt(theSpriteList, i)
  58.           set the locH of sprite theSprite to the locH of sprite theSprite - gpButtonShiftPixels
  59.           set the locV of sprite theSprite to the locV of sprite theSprite - gpButtonShiftPixels
  60.           set gpButtonIsPressed to 0
  61.         end repeat
  62.       end if
  63.     end if
  64.     updateStage()
  65.   end repeat
  66.   if gpButtonIsPressed = 1 then
  67.     repeat with i = 1 to count(theSpriteList)
  68.       set theSprite to getAt(theSpriteList, i)
  69.       set the locH of sprite theSprite to the locH of sprite theSprite - gpButtonShiftPixels
  70.       set the locV of sprite theSprite to the locV of sprite theSprite - gpButtonShiftPixels
  71.     end repeat
  72.     updateStage()
  73.   end if
  74. end
  75.